fix(rmdir): switch to another API for folder removal
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 18 Apr 2025 14:05:07 +0000 (16:05 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 24 Apr 2025 09:01:34 +0000 (11:01 +0200)
current QDir::rmdir API does not provide an error message when failing
to delete

retuse FileSystem::remove that may just works with folders

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/filesystem.cpp

index 52e8f11ad6760e54c57a0edf2fe27d1e1ade17f8..55d4c3c8b6b8c62ac6826f9a9711240a653e1911 100644 (file)
@@ -304,7 +304,8 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
         const auto parentFolderPath = fileInfo.dir().absolutePath();
         const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
         FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite);
-        allRemoved = QDir().rmdir(path);
+        auto folderDeleteError = QString{};
+        allRemoved = FileSystem::remove(path, &folderDeleteError);
         qCInfo(lcFileSystem()) << "delete" << path;
         if (allRemoved) {
             if (onDeleted)
@@ -317,7 +318,7 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
             if (onError) {
                 onError(di.filePath(), false);
             }
-            qCWarning(lcFileSystem) << "Error removing folder" << path;
+            qCWarning(lcFileSystem) << "Error removing folder" << path << folderDeleteError;
         }
     }
     return allRemoved;